CMAKE_MINIMUM_REQUIRED(VERSION 3.17)

IF (CMAKE_SYSTEM MATCHES "MANJARO")
    SET(THIRD_PARTY_X264 ${CMAKE_SOURCE_DIR}/cmake/x264/manjaro)

    IF (NOT TARGET THIRD::PARTY::X264::H)
        SET(THIRD_PARTY_X264_H ${THIRD_PARTY_X264}/include)
        ADD_LIBRARY(THIRD::PARTY::X264::H OBJECT IMPORTED)
        TARGET_INCLUDE_DIRECTORIES(THIRD::PARTY::X264::H INTERFACE "${THIRD_PARTY_X264_H}")
    ENDIF ()

    IF (NOT TARGET THIRD::PARTY::X264::LIB)
        FIND_LIBRARY(THIRD_PARTY_X264_LIB NAMES x264 PATHS ${THIRD_PARTY_X264}/lib NO_DEFAULT_PATH)
        ADD_LIBRARY(THIRD::PARTY::X264::LIB STATIC IMPORTED)
        SET_TARGET_PROPERTIES(THIRD::PARTY::X264::LIB PROPERTIES IMPORTED_LOCATION "${THIRD_PARTY_X264_LIB}")
    ENDIF ()
ELSEIF(CMAKE_SYSTEM MATCHES "Windows")
    SET(THIRD_PARTY_X264 ${CMAKE_SOURCE_DIR}/cmake/x264/windows)

    IF (NOT TARGET THIRD::PARTY::X264::H)
        SET(THIRD_PARTY_X264_H ${THIRD_PARTY_X264}/include)
        ADD_LIBRARY(THIRD::PARTY::X264::H OBJECT IMPORTED)
        TARGET_INCLUDE_DIRECTORIES(THIRD::PARTY::X264::H INTERFACE "${THIRD_PARTY_X264_H}")
    ENDIF ()

    IF (NOT TARGET THIRD::PARTY::X264::LIB)
        FIND_LIBRARY(THIRD_PARTY_X264_LIB NAMES libx264 PATHS ${THIRD_PARTY_X264}/lib NO_DEFAULT_PATH)
        ADD_LIBRARY(THIRD::PARTY::X264::LIB STATIC IMPORTED)
        SET_TARGET_PROPERTIES(THIRD::PARTY::X264::LIB PROPERTIES IMPORTED_LOCATION "${THIRD_PARTY_X264_LIB}")
    ENDIF ()
ENDIF ()